<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:include="new/head :: head"></div>
    <title>数据列表页面</title>
</head>
<body>
<fieldset id="dataConsole" class="layui-elem-field layui-field-title"  >
    <div class="layui-field-box">
        <div id="articleIndexTop">
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">分类</label>
                        <div class="layui-input-inline">
                            <select name="city">
                                <option value="0"></option>
                                <option value="1">类别1</option>
                                <option value="2">类别2</option>
                                <option value="3">类别3</option>
                            </select>
                        </div>
                        <label class="layui-form-label">关键词</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keywords" autocomplete="off" class="layui-input"/>
                        </div>
                        <div class="layui-input-inline" style="width:auto">
                            <button class="layui-btn" lay-filter="formSearch">搜索</button>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width:auto">
                            <a id="addArticle" class="layui-btn layui-btn-normal"  th:abbr="${listParam.baseurl}" onclick=" updateObj(this);">添加角色</a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</fieldset>
<fieldset id="dataList" class="layui-elem-field layui-field-title sys-list-field">
    <div class="layui-field-box">
        <div id="dataContent" class="">
            <!--内容区域 ajax获取-->
            <table style="" class="layui-table" lay-even="">
                <colgroup>
                    <col width="180"/>
                    <col/>
                    <col width="150"/>
                    <col width="180"/>
                    <col width="90"/>
                </colgroup>
                <thead >
                <tr>
                    <th>序号</th>
                    <th>角色名称</th>
                    <th>是否可用</th>
                    <th>编辑</th>
                    <th>添加权限</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="page,iterStat : ${pageImpl}">
                    <td th:text="${iterStat.index+1}"></td>
                    <td th:text="${page.name}"></td>
                    <td th:text="${page.available}"></td>
                    <div th:include="/new/list :: ud"></div>
                    <td>
                        <button class="layui-btn layui-btn-small" th:onclick="'javascript:addPermission(\''+${page.id}+'\');'">添加权限</button>
                    </td>
                </tr>
                </tbody>
            </table>

        </div>
        <div  th:include="/new/list :: hidden"></div>
        <div id="pageNav"></div>
    </div>
</fieldset>
<!-- layui规范化用法 -->
<script type="text/javascript">
    layui.config({
        base: '/style/easyCss/js/'
    }).use('datalist');
    function addPermission(id) {
        //Ajax获取
        $.post('/base/role/addPermission', {role: id}, function (data) {
            layer.open({
                type: 1,
                area: ['500px', '300px'],
                btn: ['添加', '取消'], //按钮
                btn1: function (index) {
                    $("#peradd").ajaxSubmit(function (data) {
                        if(data.indexOf("uccess")!=-1){
                            layer.msg("操作成功");
                            layer.close(index);
                        }
                    });
                },
                btn2: function () {
                },
                content: data
            });
        });
    }
</script>
</body>
</html>